package palf.visualEffects {
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.geom.Rectangle;

import palf.visualEffects.layout.Layout;
import palf.visualEffects.layout.LayoutFactory;
import palf.visualEffects.timing.Timing;
import palf.visualEffects.timing.TimingFactory;
import palf.visualEffects.transitions.Transition;
import palf.visualEffects.utils.Alignment;
import palf.visualEffects.utils.PositionData;

public class VisualEffectBuilder {

	private const LAYOUT_FACTORY : LayoutFactory = new LayoutFactory();
	private const TIMING_FACTORY : TimingFactory = new TimingFactory();

	public function VisualEffectBuilder() {

	}

	public function slideRight(target : DisplayObjectContainer, bounds : Rectangle) : void {
		var timing : Timing = TIMING_FACTORY.getDelayedTransitionOut(0.4, 0.05);
		var num_children : uint = target.numChildren;
		var child : DisplayObject;
		var data : PositionData;
		for (var i : uint = 0; i < num_children; i++) {
			child = target.getChildAt(i);
			data = new PositionData(child);
			data.x = child.x + bounds.width;
			data.y = child.y;
			timing.apply(data);
		}
	}

	public function column(target : DisplayObjectContainer, bounds : Rectangle) : void {
		var layout : Layout = LAYOUT_FACTORY.getColumnLayout(bounds, Alignment.CENTER, 10);
		var timing : Timing = TIMING_FACTORY.getDefaultTransition();
		var transition : Transition = new Transition(layout, timing);
		transition.apply(target);
	}

	public function fadeIn(target : DisplayObjectContainer) : void {
		var timing : Timing = TIMING_FACTORY.getDelayedTransition(0.4, 0.05);
		var num_children : uint = target.numChildren;
		var child : DisplayObject;
		var data : PositionData;
		for (var i : uint = 0; i < num_children; i++) {
			child = target.getChildAt(i);
			child.alpha = 0;
			data = new PositionData(child);
			data.x = child.x;
			data.y = child.y;
			data.alpha = 1;
			timing.apply(data);
		}
	}

}

}
